﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using YiSha.Business.Business;
using YiSha.Entity.Business;
using YiSha.Model.Param.Business;
using YiSha.Util;
using YiSha.Util.Model;

namespace YiSha.Admin.Web.Controllers
{
    public class EyeFollowUpController : BaseController
    {

        private EyeFollowUpBLL eyeFollowUpBLL = new EyeFollowUpBLL();

        #region 视图功能

        [AuthorizeFilter("business:eyeFollowUp:view")]
        public IActionResult EyeFollowUpIndex()
        {
            return View();
        }


        public IActionResult EyeFollowUpForm()
        {
            ViewBag.ThisDate = DateTime.Now.ToString("yyyy-MM-dd");
            ViewBag.NextFollowUpTime = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd");
            return View();
        }    

        #endregion

        #region 获取数据
        [HttpGet]
        [AuthorizeFilter("business:eyeFollowUp:search,business:eyeFollowUp:view")]
        public async Task<IActionResult> GetListJson(EyeFollowUpParam param)
        {
            TData<List<EyeFollowUpEntity>> obj = await eyeFollowUpBLL.GetList(param);
            return Json(obj);
        }

        [HttpGet]
        [AuthorizeFilter("business:eyeFollowUp:search,business:eyeFollowUp:view")]
        public async Task<IActionResult> GetPageListJson(EyeFollowUpParam param, Pagination pagination)
        {
            TData<List<EyeFollowUpEntity>> obj = await eyeFollowUpBLL.GetPageList(param, pagination);
            return Json(obj);
        }

        [HttpGet]
        public async Task<IActionResult> GetFormJson(long id)
        {
            TData<EyeFollowUpEntity> obj = await eyeFollowUpBLL.GetEntity(id);

            return Json(obj);
        }

     
        #endregion

        #region 提交数据
        [HttpPost]
        [AuthorizeFilter("business:eyeFollowUp:add,business:eyeFollowUp:edit")]
        public async Task<IActionResult> SaveFormJson(EyeFollowUpEntity entity)
        {
            TData<string> obj = await eyeFollowUpBLL.SaveForm(entity);
            return Json(obj);
        }

      

        [HttpPost]
        [AuthorizeFilter("business:eyeFollowUp:delete")]
        public async Task<IActionResult> DeleteFormJson(string ids)
        {
            TData obj = await eyeFollowUpBLL.DeleteForm(ids);
            return Json(obj);
        }
        #endregion

    }
}
